function vaild(str){
    if(!str.trim()) return -1
    var stack=[]
    var dict={']':'[','}':'{','(':')'}
    var values=Object.values(dict)
    var isbreak=-1
    for (let i = 0; i < str.length; i++) {
        var char=str.charAt(i)
        if(values.includes(char)){
            stack.push(char)
        }else if(dict[char]){
            if(!stack.length||dict[char]!=stack.pop()){
                isbreak=i
                break
            }
        }
    }
    if(isbreak>-1){
        return isbreak
    }
    return stack.length-1
}